/*
 * @Author: 'zhangkeqq' '2211709169@qq.com'
 * @Date: 2025-07-25 17:42:56
 * @LastEditors: 'zhangkeqq' '2211709169@qq.com'
 * @LastEditTime: 2025-07-25 18:14:40
 * @FilePath: \vue3-admin-node\vue3-admin\src\store\modules\userinfo.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import {defineStore} from 'pinia'
import { getUserInfo } from '@/api/userinfo/index'

export const useUserInfo = defineStore('userinfo',{
    state:()=>{
        return{
            imageUrl:'',
            name:'',
            sex:'',
            department:'',
            identity:'',
            account:'',
            email:''
        }
    },
    actions:{
        async userInfo(id:string){
            const res = await getUserInfo(id)
            if(res.status == 0){
                let data = res.data
                this.imageUrl= data.image_url
                this.name = data.name,
                this.sex = data.sex
                this.department = data.department
                this.identity = data.identity
                this.account = data.account
                this.email = data.email
            }
        }
    },
    persist:true
})